package com.toggery.POS.service;

import com.toggery.POS.entity.Brand;
import com.toggery.POS.entity.Test;
import com.toggery.POS.dao.BrandMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BrandService {
    @Autowired
    BrandMapper mapper ;

    public List<Brand> findAll(){
        return  mapper.findAll();
    }
    public boolean save(Brand brand){
        if(mapper.findById(brand.getId())==null){
            mapper.insert(brand);
            return true;
        }else {
            return false;
        }

    }
    public boolean updateBrand(Brand brand){
        if(mapper.updateByPrimaryKey(brand)>0){
            return true;
        }else {
            return false;
        }
    }
    public boolean deleteByid(int id){
        if(mapper.deleteByPrimaryKey(id)>0){
            return true;
        }else {
            return false;
        }
    }
    public Brand findById(int id){
        return mapper.findById(id);
    }
//    精确查询
    public Brand findByName(String name){
        return mapper.findByName(name);
    }
//    模糊查询
    public List<Brand> findLikeName(String name){
        //加上通配符
        name = "%"+name+"%";
        return mapper.findLikeName(name);
    }
}
